<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑</title>

</head>
<body>
<link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
<script type="text/javascript" th:src="@{/static/js/jquery-3.js}"></script>
<script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>

<style type="text/css">
    .layui-form-selectup dl{
        top:42px;
        bottom:unset;
    }
</style>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改问题</legend>
</fieldset>

<div class="layui-form-item">
    <label class="layui-form-label">问题id<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.id}" type="text" aria-readonly="true" name='id' id="id" lay-verify="required" readonly="readonly" autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">问题编号<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.number}" type="text" name='number' id="number" lay-verify="required"  autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">问题<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.question}" type="text" name='question' id="question" lay-verify="required"  autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">问题背景&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.backdrop}" type="text" name='backdrop' id="backdrop" lay-verify="required"  autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>


<div class="layui-form-item">
    <label class="layui-form-label">状态&nbsp;:</label>
    <div class="layui-input-block">
        <select name="state" id="state" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option th:selected="${questionPO.state == 0}" value="0">上架</option>
            <option th:selected="${questionPO.state == 1}" value="1">下架</option>
        </select>
    </div>
</div>


<div>
    <label class="layui-form-label">全部分类&nbsp;:</label>
    <select name="classify" id="categroy" style="width: 500px;height: 38px" lay-verify="required" class="layui-form-selectup">
        <th:block th:each="SortPO:${SortPO}">
            <option th:value="${SortPO.name}" th:selected="${SortPO.name == questionPO.sortname}">[[${SortPO.name}]]</option>
        </th:block>
    </select>
</div>

<br>

<div class="layui-form-item">
    <label class="layui-form-label">推荐&nbsp;:</label>
    <div class="layui-input-block">
        <select name="state" id="nominate" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option th:selected="${questionPO.nominate == 0}" value="0">是</option>
            <option th:selected="${questionPO.nominate == 1}" value="1">否</option>
        </select>
    </div>
</div>


<div class="layui-form-item">
    <label class="layui-form-label">置顶&nbsp;:</label>
    <div class="layui-input-block">
        <select name="state" id="top" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option th:selected="${questionPO.top == 0}" value="0">是</option>
            <option th:selected="${questionPO.top == 1}" value="1">否</option>
        </select>
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">浏览数<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.browse}" type="text" aria-readonly="true" name='browse' id="browse" lay-verify="required" readonly="readonly" autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">评论数<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.discuss}" type="text" aria-readonly="true" name='discuss' id="discuss" lay-verify="required" readonly="readonly" autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">回答数<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.answer}" type="text" aria-readonly="true" name='answer' id="answer" lay-verify="required" readonly="readonly" autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">收藏数<span style="color: red">*</span>&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${questionPO.collect}" type="text" aria-readonly="true" name='collect' id="collect" lay-verify="required" readonly="readonly" autocomplete="off"  style="width:500px;"   class="layui-input" />
    </div>
</div>

<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="editBtn">修改</button>
    </div>
</div>


<script>
    var basePath="/";

    layui.use(['form'],function () {
        var form = layui.form;
        var parentLayer = parent.layer;
        form.on("submit(editBtn)",function () {
            var obj = {
                number:$("#number").val(),//编号
                question:$("#question").val(),//问题
                backdrop:$("#backdrop").val(),//背景
                state:$("#state option:selected").val(),//状态
                sortname:$("#categroy option:selected").val(),//分类名称
                nominate:$("#nominate option:selected").val(),//推荐
                top:$("#top option:selected").val(),//置顶
                browse:$("#browse").val(),//浏览数
                discuss:$("#discuss").val(),//评论数
                answer:$("#answer").val(),//回答数
                collect:$("#collect").val(),//收藏数
            };
            $.post(basePath+"updateQuestion",obj,function (data) {
                if(data.data){
                    parentLayer.msg("修改成功",{
                        icon: 1,
                        time: 10000
                    });
                }else{
                    parentLayer.msg("修改失败",{
                        icon: 1,
                        time: 2000
                    });
                }
                parent.location.reload();
            },"json");

        })
    })
</script>



</body>
</html>